﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using Puzzler.Common;

namespace Puzzler.Plugin.Interface
{
    public abstract class PuzzleRenderer<TModel> : IPuzzleRenderer, IModelable<TModel> where TModel : PuzzleModel
    {
        public TModel Model { get; private set; }

        public Canvas Canvas { get; internal set; }

        protected PuzzleRenderer(TModel model)
        {
            model.PropertyChanged += (s, e) => DrawEditorView(Canvas);
            Model = model;
        }

        public void DrawEditorView(Canvas canvas)
        {
            if (canvas == null)
                return;

            canvas.Children.Clear();
            OnDrawEditorView(canvas);
        }

        //TODO Repaint?
        protected abstract void OnDrawEditorView(Canvas canvas);

        public abstract IList<Canvas> DrawPuzzleGameViews();
        public abstract IList<Canvas> DrawPuzzleSolutionViews();

        #region Plugin Action

        public virtual void OnInitialized()
        {
        }

        public virtual void OnDone()
        {
        }

        public virtual void OnActivated()
        {
        }

        public virtual void OnDeactivated()
        {
        }

        #endregion
    }
}
